<?php

/**
 * This is the model class for table "tbl_user_information".
 *
 * The followings are the available columns in table 'tbl_user_information':
 * @property string $pk_fk_user_id
 * @property string $username
 * @property string $true_name
 * @property string $email
 * @property integer $gender
 * @property integer $blood_type
 * @property string $portrait_url
 * @property string $user_file_url
 * @property string $user_file_id
 * @property string $user_file_suffix
 * @property integer $weight
 * @property integer $stature
 * @property string $create_time
 * @property string $update_time
 */
class TblUserInformation extends CActiveRecord
{
	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'tbl_user_information';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('pk_fk_user_id, create_time, update_time', 'required'),
			array('gender, blood_type, weight, stature', 'numerical', 'integerOnly'=>true),
			array('pk_fk_user_id', 'length', 'max'=>20),
			array('username, true_name, user_file_id', 'length', 'max'=>100),
			array('email, portrait_url, user_file_url', 'length', 'max'=>200),
			array('user_file_suffix', 'length', 'max'=>10),
			// The following rule is used by search().
			// @todo Please remove those attributes that should not be searched.
			array('pk_fk_user_id, username, true_name, email, gender, blood_type, portrait_url, user_file_url, user_file_id, user_file_suffix, weight, stature, create_time, update_time', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'pk_fk_user_id' => 'Pk Fk User',
			'username' => 'Username',
			'true_name' => 'True Name',
			'email' => 'Email',
			'gender' => 'Gender',
			'blood_type' => 'Blood Type',
			'portrait_url' => 'Portrait Url',
			'user_file_url' => 'User File Url',
			'user_file_id' => 'User File',
			'user_file_suffix' => 'User File Suffix',
			'weight' => 'Weight',
			'stature' => 'Stature',
			'create_time' => 'Create Time',
			'update_time' => 'Update Time',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 *
	 * Typical usecase:
	 * - Initialize the model fields with values from filter form.
	 * - Execute this method to get CActiveDataProvider instance which will filter
	 * models according to data in model fields.
	 * - Pass data provider to CGridView, CListView or any similar widget.
	 *
	 * @return CActiveDataProvider the data provider that can return the models
	 * based on the search/filter conditions.
	 */
	public function search()
	{
		// @todo Please modify the following code to remove attributes that should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('pk_fk_user_id',$this->pk_fk_user_id,true);
		$criteria->compare('username',$this->username,true);
		$criteria->compare('true_name',$this->true_name,true);
		$criteria->compare('email',$this->email,true);
		$criteria->compare('gender',$this->gender);
		$criteria->compare('blood_type',$this->blood_type);
		$criteria->compare('portrait_url',$this->portrait_url,true);
		$criteria->compare('user_file_url',$this->user_file_url,true);
		$criteria->compare('user_file_id',$this->user_file_id,true);
		$criteria->compare('user_file_suffix',$this->user_file_suffix,true);
		$criteria->compare('weight',$this->weight);
		$criteria->compare('stature',$this->stature);
		$criteria->compare('create_time',$this->create_time,true);
		$criteria->compare('update_time',$this->update_time,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}

	/**
	 * Returns the static model of the specified AR class.
	 * Please note that you should have this exact method in all your CActiveRecord descendants!
	 * @param string $className active record class name.
	 * @return TblUserInformation the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}
}
